<%@ page contentType="text/html; charset=utf-8" language="java"  errorPage="" %>
<%@ page import="com.netscenery.yang.model.SubModule" %>
<%@ page import="com.netscenery.yang.model.Revision" %>
<%@ page import="operate.OperateType"%>
<%@page import="offer.SessionObj"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
SubModule module = null;

Object itemNode = request.getAttribute("itemNode");
Object opType   = request.getAttribute("opType"); //获取操作对象
String optypeString = request.getParameter("opType");
if( null != itemNode){
	module = (SubModule)itemNode;
}
String modeName_suffix = module.getName();
modeName_suffix = modeName_suffix.substring(6);
String nameSpace_default = "http://www.zte.com.cn/zxr10/netconf/schema/rosng/"+modeName_suffix;
String org_default       ="ZTE Corporation \r\n";
String con_default       ="ZTE Corporation  \r\n"
        +"   Nanjing Institute of ZTE Corporation \r\n"
        +"   No.68 Zijinghua Rd. Yuhuatai District, Nanjing, China \r\n"
        +"   Tel: +86-25-52870000";
        
//Session ModuleStatus control
SessionObj sessionObj = (SessionObj)request.getSession().getAttribute("sessionObj");
String control_disabled = "";
if(!sessionObj.getModuleStatus().toString().equalsIgnoreCase("EDITING")){
 	control_disabled ="disabled='disabled'";
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Module</title>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/items.css" />
    <script type="text/javascript"  src="<%=basePath%>/js/index.js"></script>
    <script type="text/javascript"  src="<%=basePath%>jstree-v.pre1.0/_lib/jquery.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/StringUtil.js"></script>
</head>
<body  class="body">
<script type="text/javascript">
  function bodyLoad(){
   <% if( (null != itemNode) 
        &&  (!opType.toString().equalsIgnoreCase(OperateType.LOAD))){ %>
	<%   	if(opType.toString().equalsIgnoreCase(OperateType.ADD) 
	           || opType.toString().toString().equalsIgnoreCase(OperateType.MODIFY_INCLUDE_NAME)){ %>
	   		 	 //新增节点时，重新加载�
	   		 	 parent.reloadTree();
   <%   	} %>
			 $("#opNoticeSpan").html("操作成功!");
   		 	 setTimeout(function(){$("#opNoticeSpan").html("")},3000);
   <%}%>
     
     
     var date = new Date();
	 var date_month = (date.getMonth() + 1);
	 if(date_month < 10 ){
	  	date_month ="0"+date_month;
	 }
	 var date_date = (date.getDate());
	 if(date_date < 10 ){
	  	date_date ="0"+date_date;
	 }
	 var dateStr = date.getFullYear() + "-" + date_month + "-" + date_date;
	 if(document.getElementById("revision_name").value == ""){
	 	document.getElementById("revision_name").value = dateStr;
	 }
   }
   
  $(document).ready(function(){
        $("#submitButton").click(function(){
	 	     $(":input").css("border-color","");
	 	     if($("#belongs_prefix").val().trim().length == 0){
	 	     	$("#belongs_prefix").css("border-color","red");
		        alert("belongs_prefix 不能为空! ");
		        return;
	 	     }
		    document.getElementById("SubModuleForm").submit(); 
	    });
	    bodyLoad();
   })
</script>
  <form id="SubModuleForm" method="post" action="<%=basePath %>SubModuleOperateServlet" class="IndexFormStyle" >
   <div id="TableContent" class="tableContent" >
   <table border="0" class="mainTable" >
     <tr>
       <td>&nbsp;Module name:</td>
       <td>
          <input class="inputText" id="module_name" name="module_name" value="<%=module.getName()==null?"":module.getName()%>"  readonly="readonly"/>
       </td>
     </tr>
     <tr>
       <td colspan="2"  class="titleTd">BelongsTo information </td>
     </tr>
     <tr>
       <td>BelongsTo Name:</td>
       <td>
          <input class="inputText" id="belongs_name" readonly="readonly" name="belongs_name" value="<%=module.getBelongsto().getName()==null?"":module.getBelongsto().getName()%>"  />
       </td>
     </tr>
     <tr>
       <td>BelongsTo Prefix:</td>
       <td>
          <input class="inputText" id="belongs_prefix" name="belongs_prefix"  value="<%=module.getBelongsto().getPrefix()==null?"":module.getBelongsto().getPrefix() %>" />
       </td>
     </tr>
     <tr>
       <td colspan="2"  class="titleTd">
         Meta information
       </td>
     </tr>
     <tr>
       <td colspan="2" >Organization:</td>
     </tr>
     <tr>
       <td colspan="2" >
         <textarea class="textArea"  id="organization" name="organization"><%=module.getOrganization()==null?org_default:module.getOrganization() %></textarea>
       </td>
     </tr>
     <tr>
       <td colspan="2">Contact:</td>
     </tr>
     <tr>
       <td colspan="2">
         <textarea class="textArea"  id="contact" name="contact"><%=module.getContact()==null?con_default:module.getContact() %></textarea>
       </td>
     </tr>
     <tr>
       <td colspan="2">Description:</td>
     </tr>
     <tr>
       <td colspan="2">
         <textarea class="textArea"  id="description" name="description"><%=module.getDescription()==null?"":module.getDescription() %></textarea>
       </td> 
     </tr>
     <tr>
       <td colspan="2">Reference:</td>
     </tr>
     <tr>
       <td colspan="2">
         <textarea class="textArea"  id="reference" name="reference"><%=module.getReference()==null?"":module.getReference() %></textarea>
       </td>
     </tr>
     <tr>
       <td colspan="2"  class="titleTd">Revision information </td>
     </tr>
     <tr>
       <td>Revision:</td>
       <td>
          <input class="inputText" id="revision_name" name="revision_name" value="<%=module.getRevision(0)==null?"":module.getRevision(0).getName() %>" readonly="readonly" />
       </td>
     </tr>
   </table>
   </div>
   <div id="submitContent" class="submitContent">
     <span id="opNoticeSpan" style="color:red;" ></span>
     <span class="textSpan">&nbsp;</span>
     <input type="button" id="submitButton"  value="Apply" <%=control_disabled %> />
   </div>
   </form>
  </body>
</html>
